/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tletlis.model;

import java.awt.Color;
import java.util.ArrayList;
import java.util.List;

/**
 * The Red brick shaped like a Z.
 * @author Gustav
 */
public class RedBrick extends AbstractBrick {

    //Boolean for keeping track of the rotation state.
    private boolean vertical = false;

 /**
  * Constructor for initializing the shape of the brick
  * and the starting state.
  * @param y The vertical position were the brick will start.
  * @param x The horizontal position were the brick will start.
  */
    public RedBrick(int y, int x) {
        cords = new ArrayList<Position>();
        distance = Position.getLength();
        cords.add(new Position(y,x+distance));
        cords.add(new Position(y,x+(2*distance)));
        cords.add(new Position(y+distance,x));
        cords.add(new Position(y+distance,x+distance));
        color = Color.RED;
    }

 /**
  * Method returning the rotated shape of the brick.
  * @return List<Position>
  */
    @Override
    protected List<Position> rotateBrick() {
        List<Position> temp = new ArrayList<Position>();
        for(Position p: cords) {
            temp.add(new Position(p.getY(),p.getX()));
        }
        if(!vertical) {
            temp.set(2, new Position(cords.get(0).getY()-distance,cords.get(0).getX()));
            temp.set(3, new Position(cords.get(1).getY()+distance,cords.get(1).getX()));
            
        }
        else {

            temp.set(2, new Position(cords.get(0).getY()+distance,cords.get(0).getX()-distance));
            temp.set(3, new Position(cords.get(0).getY()+distance,cords.get(0).getX()));
            
        }
        return temp;
    }
    @Override
    protected void nextState() {
        vertical = !vertical;
    }
}
